<!--#include file="../lib/base.asp"-->
<%
	call islogin

	dim act:act=lcase(Cls.fget("act",0))
	select case act
		case "passdb":passdb
	end select
	
	sub passdb()
		dim t0,t1,t2
		t0=Cls.enhtml(Cls.fpost("t0",0))
		t1=Cls.enhtml(Cls.fpost("t1",0))
		t2=Cls.enhtml(Cls.fpost("t2",0))
		if Cls.strlen(t0)=0 then Cls.echo "0原密码不能为空":exit sub
		if Cls.strlen(t1)=0 then Cls.echo "0新密码不能为空":exit sub
		if Cls.strlen(t2)=0 then Cls.echo "0确认密码不能为空":exit sub
		if t1<>t2 then Cls.echo "两次密码输入不一致":exit sub
		dim data
		data=Cls.db.dbload("","","[sys_Admin]","adminid="&Cls.loadsession("adminid")&" and adminpass='"&md5(t0)&"'","")
		if ubound(data)<0 then
			Cls.echo "0原密码输入错误":exit sub
		else
			dim datanew
			datanew=array(array("adminpass",md5(t1),18,1))
			if Cls.db.dbupdate("[sys_Admin]","adminid="&Cls.loadsession("adminid")&"",datanew)=1 then
				dim t3:t3=Cls.loadcookie("loginkey")
				Cls.setcookie "loginpwd",md5(Cls.loadsession("adminname")&md5(t1)&t3) 
			end if
		end if
		Cls.echo "1"
		Cls.die
	end sub
	%>
<!--#include file="../lib/Sys_Top.asp"-->
<script>
function checkdata(the)
{
	if($.trim(the.t0.value)=="")
	{
		$.message({type:"error",content:"原密码不能为空"});
		the.t0.focus();
		return false
	}
	if($.trim(the.t1.value)=="")
	{
		$.message({type:"error",content:"新密码不能为空"});
		the.t1.focus();
		return false
	}
	if($.trim(the.t2.value)=="")
	{
		$.message({type:"error",content:"确认密码不能为空"});
		the.t2.focus();
		return false
	}
	if($.trim(the.t1.value)!=$.trim(the.t2.value))
	{
		$.message({type:"error",content:"两次密码输入不一致"});
		the.t2.focus();
		return false
	}
	var url,data;
	url="?act=passdb";
	data="t0="+encodeURIComponent($.trim(the.t0.value));
	data+="&t1="+encodeURIComponent($.trim(the.t1.value));
	data+="&t2="+encodeURIComponent($.trim(the.t2.value));
	$.ajax({
	type:"post",
	cache:false,
	url:url,
	data:data,
	error:function(){$.message({type:"error",content:"服务器错误，操作失败！"});},
	success:function(_)
	{
		var act=_.substring(0,1);
		var info=_.substring(1);
		switch(act)
		{
			case "0":
				$.message({type:"error",content:info});
				break;
			case "1":
				the.t0.value="";
				the.t1.value="";
				the.t2.value="";
				the.send.disabled=true;
				$.message({type:"ok",content:"密码修改成功"});
				setTimeout("location.href='?act=editpass'",1000);
				break;
			default:
				alert(_)
				break;
		}
	}
	});
	return false
}
</script>
</head>

<body>
    <div id="notice"><span>当前位置：</span>首页 > <a href="?">管理员设置</a> > <a href="?act=editpass">修改密码</a></div>
    <div class="clear_fixed">
       <dl class="addlist">
           <form onSubmit="return checkdata(this)">
           <dt><em>原密码：</em><input type="text" name="t0" size="30" maxlength="20" />　<span>请输入原密码</span></dt>
           <dt><em>新密码：</em><input type="text" name="t1" size="30" maxlength="20" />　<span>请输入新密码</span></dt>
           <dt><em>确认密码：</em><input type="text" name="t2" size="30" maxlength="20" />　<span>必须和上面的新密码保持一致</span></dt>
           <dd><input type="submit" name="send" value="修改" /><input type="button" value="返回" onClick="location.href='javascript:history.go(-1)'" /></dd>
           </form>
       </dl>
</div>
</body>
</html>
